/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.usecase.figure;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.SWT;

import com.cea.papyrus.core.figures.NodeFigure;

/**
 * Defines the view of an actor in its stickman form.
 * 
 * @author Gilles Cannenterre
 * @since 9 oct. 06
 */
public class ActorStickmanFormFigure extends NodeFigure {

	/**
	 */
	protected static final int ACTOR_THICKNESS = 1;
	/**
	 * The Constructor.
	 * 
	 * @param numberNode the number node
	 */
	public ActorStickmanFormFigure(){
		super();
	}

	/**
	 * Sets the name.
	 * 
	 * @param name the name
	 */
	@Override
	public void setName( String name ) {}

	/**
	 * Sets the qualified name.
	 * 
	 * @param packageName the package name
	 */
	@Override
	public void setQualifiedName( String packageName ){}

	/**
	 * Set the stereotype value.
	 * If param is null, remove the label.
	 * 
	 * @param stereotypes the stereotypes
	 */
	@Override
	public void setStereotypes( String stereotypes ){}

	/**
	 * Paint border.
	 * 
	 * @param graphics the graphics
	 */
	@Override
	public void paintBorder(Graphics graphics){	}

	/* (non-Javadoc)
	 * @see com.cea.papyrus.common.figures.NodeFigure#paintFigure(org.eclipse.draw2d.Graphics)
	 */
	@Override
	public void paintFigure(Graphics graphics) {
		graphics.pushState();
		graphics.setAntialias(SWT.ON);
		Rectangle actorArea = getBounds();
		int height = actorArea.height;
		int width = actorArea.width;
				
		// Calculate points 
		Point rightArm = new Point(actorArea.getBottomRight().x,(int)(actorArea.y + 5*height/12));
		Point leftArm = new Point(actorArea.getBottomLeft().x,(int)(actorArea.y + 5*height/12));
		
		Point middleLeg = new Point((int)(actorArea.x + width/2),(int)(actorArea.y + 2*height/3));
		Point rightLeg = actorArea.getBottomRight();
		Point leftLeg = actorArea.getBottomLeft();
		
		Point neck = new Point((int)(actorArea.x + width/2),(int)(actorArea.y + height/3));
		Point positionHead = new Point((int)(actorArea.x + width/4),actorArea.getTop().y);
		
		// Draw body and head
		graphics.setLineWidth(ACTOR_THICKNESS);
		graphics.setForegroundColor(getBorderColor());
		graphics.drawLine(rightArm, leftArm);
		graphics.drawLine(middleLeg, rightLeg);
		graphics.drawLine(middleLeg, leftLeg);
		graphics.drawLine(middleLeg, neck);
		
		graphics.drawOval(positionHead.x, positionHead.y, width/2, height/3);
		// graphics.fillOval(positionHead.x+1, positionHead.y+1, width/2-1, height/3-1);
		
		graphics.popState();
	}
}